<?php
function smarty_function_catalog_list($params, &$smarty)
{
	include($_ENV['webpath']."conn.php");
	include_once($_ENV['webpath']."model/article.php");
	
	$sqladd='';
	$page=$params['page']?$params['page']:1;
	if(!$params['showall']){
		$sqladd.=' and c_show=1';
	}
	if($params['type']){
		$sqladd.=" and type='".$params['type']."'";
	}
	if($params['order']){
		$sqladd.=' order by '.$params['order'];
	}else{
		$sqladd.=' order by paixu';
	}
	if($params['count']){
		$sqladd.=' limit '.($page-1)*$params['count'].",".$params['count'];
	}
    if($params['pid']){
		$sql="select * from ".$prefix."column where pid=".$params['pid'].$sqladd;
	}else{
		$sql="select * from ".$prefix."column where pid=0".$sqladd;
	}
	
	$result=mysql_query($sql);
	while($row=mysql_fetch_array($result)){
		$row['path']=get_catalog_path_all($row['id']);
		$arr[]=$row;
	}
	if (empty($params['assign'])) {
		return $arr;
	} else {
		$smarty->assign($params['assign'],$arr);
	}
	mysql_close($conn);
}
?>
